import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace ServiceRequestApi {
  /** 服务申请信息 */
  export interface ServiceRequest {
    id?: number;
    // TODO: 添加字段
  }

  /** 服务申请分页查询参数 */
  export interface ServiceRequestPageReqVO extends PageParam {
    createTime?: string[];
    // TODO: 添加查询条件字段
  }
}

/** 查询服务申请分页 */
export function getServiceRequestPage(params: ServiceRequestApi.ServiceRequestPageReqVO) {
  return requestClient.get<PageResult<ServiceRequestApi.ServiceRequest>>(
    '/cmt/service-request/page',
    { params },
  );
}

/** 查询服务申请详情 */
export function getServiceRequest(id: number) {
  return requestClient.get<ServiceRequestApi.ServiceRequest>(
    `/cmt/service-request/get?id=${id}`,
  );
}

/** 新增服务申请 */
export function createServiceRequest(data: ServiceRequestApi.ServiceRequest) {
  return requestClient.post('/cmt/service-request/create', data);
}

/** 修改服务申请 */
export function updateServiceRequest(data: ServiceRequestApi.ServiceRequest) {
  return requestClient.put('/cmt/service-request/update', data);
}

/** 删除服务申请 */
export function deleteServiceRequest(id: number) {
  return requestClient.delete(`/cmt/service-request/delete?id=${id}`);
}

/** 批量删除服务申请 */
export function deleteServiceRequestList(ids: number[]) {
  return requestClient.delete(
    `/cmt/service-request/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出服务申请 */
export function exportServiceRequest(params: any) {
  return requestClient.download('/cmt/service-request/export-excel', { params });
}
